import { Dept } from "@/api/interface/index";
import http from "@/api";
import { deptAnonymous } from "@/utils/constants";

/**
 * @name 分组管理模块
 */
// * 获取菜单列表
export const getDeptList = async (params?: any) => {
	let res = await http.get<Dept.DeptRows>(`/dept/find`, params, { headers: { noLoading: true } });
	for (let i = 0; i < res.result.records.children.length; i++) {
		if (res.result.records.children[i].id == deptAnonymous) {
			res.result.records.children.splice(i, 1);
			break;
		}
	}
	return res;
};

// * 新增分组
export const addDept = (params: any) => {
	return http.post(`/dept/add`, params);
};

// * 编辑分组
export const editDept = (params: any) => {
	return http.post(`/dept/modify`, params);
};

// * 删除分组
export const deleteDept = (params: { id: string; ids?: string }) => {
	return http.post(`/dept/remove`, params);
};
